﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    public class ItemOfficeCount
    {
        /// <summary>
        /// dal定义的便利
        /// </summary>
        private readonly DAL.ItemOfficeCount dal = new DAL.ItemOfficeCount();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetAll(string itemClsNo, string startDate, string endDate)
        {
            return dal.GetAll(itemClsNo, startDate, endDate);
        }


        /// <summary>
        ///  获得数据列表
        /// <summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-9</date>
        /// </summary>
        /// <param name="dt">一张DataTable</param>
        /// <returns>返回Model</returns>
        public List<Model.ItemOfficeCount> DataTableToListItemCount(DataTable dt)
        {
            List<Model.ItemOfficeCount> modelList = new List<Model.ItemOfficeCount>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.ItemOfficeCount model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.ItemOfficeCount();
                    if (dt.Rows[n]["FItemClsNo"] != null)
                    {
                        model.FItemClsNo = dt.Rows[n]["FItemClsNo"].ToString();
                    }
                    if (dt.Rows[n]["FItemNo"] != null)
                    {
                        model.FItemNo = dt.Rows[n]["FItemNo"].ToString();
                    }
                    if (dt.Rows[n]["FItemName"] != null)
                    {
                        model.FItemName = dt.Rows[n]["FItemName"].ToString();
                    }
                    if (dt.Rows[n]["amount1"] != null && dt.Rows[n]["amount1"].ToString() != "")
                    {
                        model.amount1 = decimal.Parse(dt.Rows[n]["amount1"].ToString());
                    }
                    if (dt.Rows[n]["qty1"] != null && dt.Rows[n]["qty1"].ToString() != "")
                    {
                        model.qty1 = decimal.Parse(dt.Rows[n]["qty1"].ToString());
                    }
                    if (dt.Rows[n]["amount2"] != null && dt.Rows[n]["amount2"].ToString() != "")
                    {
                        model.amount2 = decimal.Parse(dt.Rows[n]["amount2"].ToString());
                    }
                    if (dt.Rows[n]["qty2"] != null && dt.Rows[n]["qty2"].ToString() != "")
                    {
                        model.qty2 = decimal.Parse(dt.Rows[n]["qty2"].ToString());
                    }
                    if (dt.Rows[n]["FApplyQty"] != null)
                    {
                        model.FApplyQty = dt.Rows[n]["FApplyQty"].ToString();
                    }
                    if (dt.Rows[n]["FItemSpec"] != null)
                    {
                        model.FItemSpec = dt.Rows[n]["FItemSpec"].ToString();
                    }
                    if (dt.Rows[n]["FItemClsName"] != null)
                    {
                        model.FItemClsName = dt.Rows[n]["FItemClsName"].ToString();
                    }
                    if (dt.Rows[n]["FEntityNo"] != null)
                    {
                        model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }


    }
}
